mainTaskMgr = {}
QMPlugin = mainTaskMgr
mainTaskMgr.aaa = 1
function mainTaskMgr.init()
    mainTaskMgr.monsterList = {
        { name = "蝙蝠", params = {
            {"213365","-22|-46|264B9D,-19|-59|2B4797,-20|45|224398,-19|62|215099",0,0.9},
        } },
        { name = "软泥怪", params = {
            {"000101","2|-14|4F4D50,6|-43|4C485A,30|-8|A8A84C,48|-7|767465,-29|-2|4D474B",0,0.9},
            {"000101","2|-14|4F4D50,6|-43|4C485A,30|-8|A8A84C,48|-7|767465,-29|-2|4D474B",0,0.9},
        } },
    }
    mlog.info("mainTaskMgr init >>>>>>>>>>>")
end

local function CheckMainTaskItemPos()
    local itemX,itemY = game.findMultiColor(485,1071,522,1218,"26B3F9","-5|-3|26A2DD,-10|0|00A5FF,-16|-5|00A5FF",0,0.85)
    if itemX == -1 or itemY == - 1 then
        return false
    else
        return true
    end
end

local function ClickMainTaskItem()
    mlog.info("寻找主线任务")
    local itemX,itemY = game.findMultiColor(108,1070,517,1277,"26B3F9","-5|-3|26A2DD,-10|0|00A5FF,-16|-5|00A5FF",0,0.85)
    if itemX == -1 or itemY == - 1 then
        mlog.info("没找到主线任务")
    else
        itemX = itemX - 40
        itemY = itemY + 100
        game.tap(itemX, itemY)
        mlog.info(string.format("找到并点击主线任务 x=%s y=%s", tostring(itemX), tostring(itemY)))
    end
end

local function ProcessMainTaskItemPos()
    local times = 0
    while not CheckMainTaskItemPos() do
        local itemX,itemY = game.findMultiColor( 108,1070,517,1277,"26B3F9","-5|-3|26A2DD,-10|0|00A5FF,-16|-5|00A5FF",0,0.85)
        if itemX == -1 or itemY == - 1 then
        else
            itemX = itemX - 40
            itemY = itemY + 100
            game.tap(itemX, itemY)
            game.delay(500)
        end
        game.delay(500)
        times = times + 1
        if times > 10 then
            return false
        end
    end

    return true
end

function mainTaskMgr.execMainTask()
    while true do
        -- 处理意外弹框
        -- 检查处理新手引导
        accidentEvent.check()
        -- 开始点击主线任务
--        ClickMainTaskItem()
--        game.WaitFindWayFinish()
--        game.delay(500)
    end

end